//
//  NSObject+TY.m
//  高仿暴走斗图
//
//  Created by huangsongyao on 16/4/4.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "NSObject+TY.h"

@implementation NSObject (TY)

+ (TYTextContainer *)createTextContainerWithCharacterSpacing:(unichar)characterSpacing andLinesSpacing:(CGFloat)linesSpacing text:(NSString *)text textColor:(UIColor *)textColor font:(UIFont *)font {
    
    TYTextContainer *textContainer = [[TYTextContainer alloc] init];
    textContainer.characterSpacing = characterSpacing;
    textContainer.linesSpacing = linesSpacing;
    textContainer.text = text;
    
    textContainer.textColor = textColor;
    textContainer.font = font;
    
    return textContainer;
}


+ (TYAttributedLabel *)createAttributedLabelForDelegate:(id<TYAttributedLabelDelegate>)delegate withTextContainer:(TYTextContainer *)textContainer frame:(CGRect)frame {
    
    TYAttributedLabel *attributedLabel = [[TYAttributedLabel alloc] initWithFrame:frame];
    attributedLabel.textContainer = textContainer;
    if (delegate) {
        attributedLabel.delegate = delegate;
    }
    
    [attributedLabel sizeToFit];
    
    return attributedLabel;
}

+ (void)parseTextContainerForString:(NSString *)string withUsingBlock:(void(^)(NSInteger captureCount, NSString *const __unsafe_unretained *capturedStrings, const NSRange *capturedRanges, volatile BOOL *const stop))usingBlock {

    if (string.length == 0) {
        return;
    }
    [string enumerateStringsMatchedByRegex:@"\\[@\\]" usingBlock:usingBlock];
}

@end
